package com.msconfig.mvp.view.fragment;

/*
 * author: caojunhao
 * date  : 2020/4/28
 * desc  :
 */

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.geo.msconfig.R;
import com.msconfig.device.DeviceManage;
import com.msconfig.event.NullEvent;
import com.msconfig.io.ConnectListener;
import com.msconfig.mvp.view.activity.base.BaseMvpActivity;
import com.msconfig.mvp.view.activity.base.BaseMvpFragment;
import com.msconfig.mvp.view.activity.base.BasePresenter;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.List;

public class EquipmentPageFragment extends BaseMvpFragment implements View.OnClickListener{
    private LinearLayout llEquipmentInformation;
    private LinearLayout llEquipmentFirmwareUpdate;
    private LinearLayout llEquipmentObservationDocuments;

    public static EquipmentPageFragment newInstance() {
        Bundle args = new Bundle();
        EquipmentPageFragment fragment = new EquipmentPageFragment();
        fragment.setArguments(args);
        return fragment;
    }


    @Override
    protected int getLayoutId() {
        return R.layout.layout_fragment_equitment;
    }

    @Override
    protected void initView(View view) {

        llEquipmentInformation=view.findViewById(R.id.ll_equipment_information);
        llEquipmentFirmwareUpdate=view.findViewById(R.id.ll_equipment_firmware_update);
        llEquipmentObservationDocuments=view.findViewById(R.id.ll_equipment_observation_documents);

    }

    @Override
    protected void initListener(View view) {

        llEquipmentInformation.setOnClickListener(this);
        llEquipmentFirmwareUpdate.setOnClickListener(this);
        llEquipmentObservationDocuments.setOnClickListener(this);

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void createPresenter(List<BasePresenter> mPresenters) {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.ll_equipment_information:
                if(!DeviceManage.getInstance().isConnected()){
                    Toast.makeText(getContext(), R.string.toast_none_connect, Toast.LENGTH_SHORT).show();
                    return;
                }
                ((BaseMvpActivity)getActivity()).goToNextFragment(this, EquipmentInformationFragment.newInstance());
                break;
            case R.id.ll_equipment_firmware_update:
                Toast.makeText(getContext(), R.string.toast_soon, Toast.LENGTH_SHORT).show();
                //((BaseMvpActivity)getActivity()).goToNextFragment(this, EquipmentFirmwareUpdateFragment.newInstance());
                break;
            case R.id.ll_equipment_observation_documents:
                Toast.makeText(getContext(),R.string.toast_soon, Toast.LENGTH_SHORT).show();
                //((BaseMvpActivity)getActivity()).goToNextFragment(this, EquipmentObservationDocumentsFragment.newInstance());
                break;
        }

    }

    //目前这里只是为了实现eventbus
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void haveNull(NullEvent event) {
    }
}
